package com.myrslok;

import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Abstraction of task for a compiler, specifying source files, classpath, options and related things.
 */
public class CompileRequest {

    private static final Logger logger = LoggerFactory.getLogger(CompileRequest.class);

    private final List<String> srcDirs = new ArrayList<String>();
    private final String targetDir;
    private final Set<File> classPath;
    private boolean logCompilerSettings;

    public CompileRequest(@NotNull final Set<File> srcDirs, @NotNull final File targetDir) {
        for (@NotNull final File srcDir : srcDirs) {
            this.srcDirs.add(srcDir.getPath());
            if (srcDir.mkdirs()) {
                logger.info("Created dir {}", srcDir);
            }
        }
        this.targetDir = targetDir.getPath();
        this.classPath = new HashSet<File>();
    }

    public List<String> getSrcDirs() {
        return srcDirs;
    }

    public String getTargetDir() {
        return targetDir;
    }

    public void addToClassPath(@NotNull final File classPathElement) {
        classPath.add(classPathElement);
    }

    public Set<File> getClassPath() {
        return classPath;
    }
}